package br.com.vti.sisp_sicrim.controller;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.Validator;
import br.com.crud4j.core.model.business.Business;
import br.com.crud4j.core.util.MessageResolver;
import br.com.crud4j.vraptor3.controller.ControllerImpl;
import br.com.vti.sisp_sicrim.model.entity.Delegacia;
import br.com.vti.sisp_sicrim.model.entity.Incidencia;
import br.com.vti.sisp_sicrim.modelo.business.exception.DelegaciaException;
import br.com.vti.sisp_sicrim.modelo.business.exception.IncidenciaException;

@Resource
@Path("/pages/incidencia")
public class IncidenciaController extends ControllerImpl<Incidencia, IncidenciaException> {

	private final Business<Delegacia, DelegaciaException> delegaciaBusiness;
	
	@Autowired
	public IncidenciaController(Result result, Validator validator,
			@Qualifier("incidenciaBusiness") Business<Incidencia, IncidenciaException> entidadeBusiness,
			@Qualifier("delegaciaBusiness") Business<Delegacia, DelegaciaException> delegaciaBusiness,
			MessageResolver messageResolver) {
		super(result, validator, entidadeBusiness, messageResolver);
		this.delegaciaBusiness=delegaciaBusiness;
	}

    protected Business<Delegacia, DelegaciaException> getDelegaciaBusiness() {
		return delegaciaBusiness;
	}

    
	@PostConstruct
    protected void limpar() {
        include("delegaciaList", getDelegaciaBusiness().listar(null));
    }

}
